home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-03-19 | 37.3 KB | 1,089 lines | [TEXT/MPS ] |
- #########################################################################
- #########################################################################
- ## Copyright © Apple Computer, Inc. 1992-1997
- ## All rights reserved
- #########################################################################
- #########################################################################
- #
- # Library: Additions.lib
- #
- # Version: 2.1.4
- #
- # Description: Useful Clouseau tasks that don't fit in other libraries.
- #
- # Contains:
- # select_named_item()
- # point_to_sys_icon()
- # headerCoords()
- # ClearViews()
- # ClickViewsBoxes()
- # SetDefaultViews()
- # scrapBook()
- # readScrollingList()
- # offset_list()
- # CenterOfWindowClick()
- # hexStr_to_dec()
- # unexpected_dialog()
- # abort_app()
- # quit_all()
- #
- # History:
- # Date: By: Changes:
- # 05/15/92 Jason Marsh Created
- # 05/15/92 Jonathan Marsh Created
- # 05/15/92 SBR Created
- # 02/19/94 SBR Changed
- # 09/04/95 SBR Added this header for Radar 1273927
- # Changes to Scrapbook
- # 09/27/96 SBR/BRL/MSO Updated copyright headers
- # Use SPEC exception handling method (ExceptionHandling.lib)
- # 01/21/97 SBR Deleted older exception code and comments.
- #
- #########################################################################
-
- Libraries
- "Clouseau.lib",
- "ExceptionHandling.lib",
- "Report.lib",
- "TargetControl.lib",
- "VUAid.lib";
-
- #########################################################################
- # task select_named_item(name)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Selects an item by its name in an open window, checks
- # with get info
- # Parameters: name: string - name of icon to open
- # Returns: true: if successful
- # false: if unsuccessful
- # Examples: select_named_item('Mouse');
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 5/15/93 Jonathan Marsh Created
- #########################################################################
- task select_named_item(name)
- begin
- rStatus("select_named_item: " + name, 4);
- type_keys({tabKey, name, 'latch', commandKey, 'i'}); #tab insures we don't rename items
- if not await_presence([window t:(name + ' Info')],3,,,6) begin
- key_eq('w',,6);
- return RIncomplete("select_named_item: Could not find item named: {name}", 4);
- end;
- key_eq('w');
- return true;
- end;
-
-
- #########################################################################
- # task point_to_sys_icon(PathName, IconName, WindowName, large)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Points to and highlights an icon in a window.
- # Parameters: PathName:the path to the window that contains the icon
- # IconName: name of icon to point to
- # if 'header' is passed in as the IconName, the mouse is moved to the window header.
- # WindowName: the window containing the icon
- # large: Large icon view or small icon view
- # Returns: true: if successful
- # false: if unsuccessful
- # Examples: point_to_icon('Mouse');
- # Assumptions: Window must be icon view, this will not check to confirm
- # it, as checking is slow.
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 06/01/92 Jason Marsh Created
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task point_to_sys_icon(PathName, IconName, WindowName, large := false)
- begin
- RStatus("point_to_sys_icon: " + PathName + ":" + IconName,4);
-
- select_window(WindowName);
-
- _Type({tabKey}); #Make sure renaming doesn't happen
-
- if IconName = 'header'
- return headerCoords();
-
- try
- match [window t:$oldWindows];
- catch theError
- ExceptionDispatcher(theError,,{"match 1 in point_to_sys_icon", {PathName, IconName, WindowName, large}});
-
- type_keys({IconName, 'down', commandKey, 'latch', optionKey, UpArrowKey, 'up', commandKey});
-
- try
- match [window t:?currentWindow o:1 r:?windRect];
- catch theError
- ExceptionDispatcher(theError,,{"match 2 in point_to_sys_icon", {PathName, IconName, WindowName, large}});
-
- if isMember(currentWindow, oldWindows)
- type_keys({'latch', commandKey, DownArrowKey});
- else
- type_keys({'down', commandKey, 'latch', optionKey, DownArrowKey, 'up', commandKey});
-
- wait(2);
-
- IconLoc:= VUAid("IconLocation", {PathName + ":" + IconName},6);
- if IsUndefined(IconLoc) return RIncomplete("point_to_sys_icon: icon is not present or path is incorrect",4);
-
- if windowName = "Apple Menu Items" IconLoc := replace(IconLoc[1] + 15, 1, IconLoc);
-
- if large #click on center of first letter of name, then move mouse to center of icon
- move_mouse({{iconLoc[1] + 1 + 15,iconLoc[2] + 39 + 39}, 'click', 'relative', {0, -10}});
- else
- move_mouse({{iconLoc[1] + 1 + 20,iconLoc[2] + 39 + 9}, 'click', 'relative', {-10, 0}});
-
- return true;
- end;
-
- #########################################################################
- # task headerCoords()
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Moves mouse to the window title, ready for a pop-up
- # menu navigation.
- # Parameters: None
- # Returns: true
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 06/01/92 Jason Marsh Created
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task headerCoords()
- begin
- try
- match [window o:1 r:?Windrect];
- catch theError
- ExceptionDispatcher(theError,,{"match in headerCoords", {[window o:1], false}});
- x:= (Windrect[3] + Windrect[1]) / 2 ;
- y := Windrect[2] +10;
-
- _Move('a', {x,y});
- return true;
- end;
-
-
- #########################################################################
- # task ClearViews(v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: clears all check boxes in Views CDEV.
- # Parameters: none
- # Returns: true: if successful
- # false: if unsuccessful
- # Examples: ClearViews();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 04/12/92 SBR Created
- # 2/15/94 GTK Updated whichCheckSum checksums.
- # Changed the checkbox rects to 16 pixels, which
- # is neccesary for CompareWindowRect to return
- # consistent checksums at 1-bit depth.
- #########################################################################
- task ClearViews(v_level:=5) #clears all checkboxes in the ViewsCP
- begin
- BoxLocList:= {{'size', {210,155}}, {'kind',{210,170}}, {'label', {210,185}}, {'date',{210,200}},
- {'version',{210,215}}, {'comments', {210,230}}, {'calculate',{29,215}}, {'disk',{29,230}}, {'snap to grid',{210,100}}};
-
- CurBitDepth := VUAid("GetDepth");
-
- RStatus("Clearing all CheckBoxes in the Views Control Panel",v_level);
-
- NotEnabled := VUAid("CompareWindowRect", {201, 128, 217, 144} ,4);
- if "{NotEnabled}" = WhichCheckSum({'-14440','21544','24544','-16448','28864','unknown'},CurBitDepth)
- move_mouse({{210,155}, 'click'},,4);
-
- Enabled := VUAid("CompareWindowRect", {20, 188, 36, 204}, 4);
- if "{Enabled}" = WhichCheckSum({'8472','20152','4080','8160','-24448','unknown'},CurBitDepth)
- move_mouse({{29,215}, 'click'},,4);
-
- for i:= 1 to card BoxLocList
- begin
- Bttn := BoxLocList[i][2];
- WindTopX:= Bttn[1] - 9;
- WindTopY:= Bttn[2] - 27;
- WindBottomX:= WindTopX + 16;
- WindBottomY:= WindTopY + 16;
-
- Enabled := VUAid("CompareWindowRect", {WindTopX, WindTopY, WindBottomX, WindBottomY} ,4);
- if "{Enabled}" = WhichCheckSum({'8472','20152','4080','8160','-24448','unknown'},CurBitDepth)
- move_mouse({Bttn, 'click'},,4);
-
- end;
- return true;
- end;
-
- #########################################################################
- # task ClickViewsBoxes(BoxList, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Clicks the boxes determined by BoxList parameter
- # Parameters: BoxList : a list of strings each of which can be:
- # 'snap to grid', 'size', 'kind', 'label',
- # 'date', 'version', 'comments', 'calculate'
- # v_level: verbosity of log output
- # Returns: true: if successful
- # false: if unsuccessful
- # Examples: ClickViewsBoxes({'size', 'version'});
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 04/12/92 JDM Created
- #########################################################################
- task ClickViewsBoxes(BoxList:={}, v_level := 5) #sets the boxes specified in BoxList
- begin
- if not select_window("Views") return false;
-
- if RXStatus(v_level) println "Clicking in Views Boxes ", {BoxList};
-
- MMActionList:={};
- BoxLocList:= {{'size', {210,155}}, {'kind',{210,170}}, {'label', {210,185}}, {'date',{210,200}},
- {'version',{210,215}}, {'comments', {210,230}}, {'calculate',{29,215}}, {'disk',{29,230}}, {'snap to grid',{210,100}}};
-
-
- for i := 1 to card BoxList
- MMActionList := MMActionList + {assoc(BoxList[i],BoxLocList)} + {'click'};
- move_mouse(MMActionList,,4);
- end;
-
-
- #########################################################################
- # task SetDefaultViews(v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Sets the views to 'Easy install default'
- # Parameters: v_level: verbosity of log output
- # Returns: Nothing
- # Examples: SetDefaultViews();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 04/12/92 JDM Created
- # 11/18/93 JDL Removed statements to close Control Panels
- # window behind Views control panel; new version
- # of open_control_panel takes care of closing.
- # 02/15/94 GTK Commented out the "default" check because it's
- # not working correctly.
- # Removed "snap to grid" from the ClickViewsBoxes
- # parm list because it is unchecked by default.
- # 09/10/94 SBR Changed the variable "default" to "defaultVal"
- # because "default" is now a keyword
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task SetDefaultViews(v_level := 5)
- begin
- if not _MatchBoolean([window t:"Views"])
- begin
- if not open_control_panel("Views")
- return false;
- end;
- else if not select_window("Views")
- return false;
-
- key_eq('a');
- _Type({"9", returnKey});
- move_mouse({{95,89},'click', {59,188}, 'click', 'wait1'});
-
- if not select_descriptor([menuItem t:"Geneva" m:[popup e:true]]!, 4)
- return RIncomplete("Incomplete: unable to change to requested font", v_level);
-
- ### GTK - The following test has been commented out for now because CompareWindowRect
- ### always seems to return the same checksum no matter what the state of the checkboxes.
- ### This causes the test to always evaluate to true, thereby returning without setting
- ### the Views window to the default values.
- # defaultVal := VUAid("CompareWindowRect", {1, 43, 255, 236});
- # if "{defaultVal}" = whichCheckSum({ '10240','23552','-31744','-15360','-32264','xxx' })
- # return true;
-
- RStatus("Setting Defaults for Views Control Panel, checksum: {defaultVal}",v_level);
-
- ClearViews(v_level);
- ClickViewsBoxes({'size', 'kind', 'label', 'date'},v_level);
- return true;
- end;
-
-
- #########################################################################
- # task scrapBook(actionList)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Opens, performs actions, and closes Scrapbook.
- # Parameters: ActionList: List of actions to perform, including:
- # menu item names:
- # "Cut", "Copy", "Paste", "Clear", "Undo", "Close", "Quit", etc.
- # other actions:
- # {"launch"} #select Scrapbook from Apple menu
- # {"twitch"} #select Scrapbook from Process menu
- # {"twitch back"} #twitch back to the initial app
- # {"scroll", position} #scroll to position
- # {"find", type, startPos, endPos} #find scrap type,
- # #look between startPos and endPos items
- # {"verify", type} #verify that current item is of correcttype
- # {"play"} #click on the play button
- # Returns: true if good actionList, false if illegal items encountered
- # Examples: scrapBook({{"launch"}, {"find","PICT",5,6}, "Cut", "Quit"});
- # Assumptions: Requires VUAid 2.0
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 04/09/92 Jon Marsh Created
- # 02/15/94 Gary Kratzer Changed scrapTypeRect rect because it was not
- # within the bounds of the scrapbook item's type.
- # Updated scrapTypes checksums.
- # 03/30/94 Gary Kratzer Changed to support Capone Scrapbook.
- # 04/12/94 Gary Kratzer More changes to support Capone Scrapbook.
- # 09/04/95 SBR Formatted according to standards.
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task scrapBook(actionList:= {})
- begin
- currentApp := _Match([application]).t;
-
- SSWVersion := _Gestalt('sysv')[2][2];
-
- SSWVersion := numToStr(SSWVersion, 16); # Convert from base 16
- if SSWVersion >= '0x750' # If System 7.5 or greater
- begin
- scrapTypes := {
- { "snd ", { 22400,28368,-12224,3040,23188,'xxx' } },
- { "TEXT", { -29392,1312,-7920,2976,31508,'xxx' } },
- { "PICT", { 19456,-3344,6768,13696,14164,'xxx' } }
- };
- scrapTypeRect := {61, 226, 146, 237};
- end;
- else
- begin
- scrapTypes := {
- { "snd ", { 11072,15696,15264,3040,23188,'xxx' } },
- { "TEXT", { 8016,1312,-7920,2976,31508,'xxx' } },
- { "PICT", { -31792,-29184,6768,13696,14164,'xxx' } }
- };
- scrapTypeRect := {288, 234, 373, 245};
- end;
-
- for each action in actionList
- begin
- actionIllegal := false;
- actionPassed := false;
- if typeof(action) = 'list'
- begin
- if action[1] = "launch"
- begin
- select_menuItem("Scrapbook");
- if await_presence([window o:1 t:"Scrapbook"],,, true)
- begin
- RStatus("Launched ScrapBook DA", 4);
- if SSWVersion >= '0x750' # If System 7.5 or greater
- _Size([window o:1 t:"Scrapbook"], 'wh', {387,277}); # Size same as old Scrapbook
- end;
- else
- actionPassed:= RError("Failed: Unable to launch ScrapBook DA");
- end;
- else if action[1] = "twitch"
- begin
- twitch("Scrapbook");
- RStatus("Twitched to Scrapbook", 4);
- end;
- else if action[1] = "twitch back"
- begin
- twitch(currentApp);
- RStatus("Twitched to previous app - {currentApp}", 4);
- end;
- else if action[1] = "play"
- begin
- if select_descriptor([button t:"Play Sound"])
- RStatus("Played sound from scrapbook", 4);
- else
- actionPassed:= RError("Failed: Couldn't find Play Sound Button in scrapbook");
- end;
- else if action[1] = "scroll"
- begin
- if typeOf(action[2]) = 'integer'
- begin
- requested := action[2];
-
- controlWithNoName := _Match ([control t:''], true);
-
- if controlWithNoName
- begin
- scrollStatus := controlWithNoName.s;
- if scrollStatus[2] + 1 < requested
- requested := scrollStatus[2] + 1;
- if requested < 1
- requested := 1;
-
- _Scroll([scrollBar w:1], 'a', {requested - 1, scrollStatus[2]});
-
- scrollStatus := _Match ([control t:''], true).s;
-
- if scrollStatus[1] + 1 = requested
- RStatus("Scrolled to item {requested} of scrapbook",4);
- else
- actionPassed:= RError("Failed: Scroll to item {requested} of scrapbook failed");
- end;
- else
- actionPassed:= RIncomplete("Incomplete: Couldn't find scroll bar in scrapbook");
- end;
- else
- actionIllegal := true;
- end;
- else if action[1] = "find"
- begin
- if typeOf(action[2]) = 'string'
- begin
- requested := action[2];
- startPosition := action[3];
- endPosition := action[4];
- if typeOf(startPosition) <> 'integer'
- startPosition := 1;
- if typeOf(endPosition) <> 'integer'
- endPosition := 9999;
-
- checkList:= assoc( requested, scrapTypes);
- if checkList
- begin
- controlWithNoName := _Match ([control t:''], true);
-
- if controlWithNoName # new logic 8/30/96
- begin
- scrollStatus := controlWithNoName.s;
- if scrollStatus[2] + 1 < startPosition
- startPosition := scrollStatus[2] + 1;
- if startPosition < 1
- startPosition := 1;
- if scrollStatus[2] + 1 < endPosition
- endPosition := scrollStatus[2] + 1;
-
- found := false;
- searchPosition := startPosition;
- if typeOf(bitDepth) <> 'integer'
- bitDepth := VUAid("GetDepth");
-
- while (not found) and (searchPosition <= endPosition)
- begin
- _Scroll([scrollBar w:1], 'a', {searchPosition - 1, scrollStatus[2]});
-
- scrollStatus := _Match ([control t:''], true).s;
-
- if scrollStatus[1] + 1 <> searchPosition
- begin
- actionPassed:= RIncomplete("Incomplete: Scroll to item {startPosition} of scrapbook failed");
- searchPosition := 9999;
- end;
- else
- begin
- expected := whichCheckSum(checkList, bitDepth);
- actual := VUAid("CompareWindowRect", scrapTypeRect);
- if actual = expected
- begin
- found := true;
- RStatus("Verified: Found entry of type {requested} at position {searchPosition}", 4);
- end;
- searchPosition := searchPosition + 1;
- end;
- end;
- if not found
- actionPassed:= RError("Failed: Could not find entry of type {requested} between items {startPosition} and {endPosition}");
- end;
- else
- actionPassed:= RIncomplete("Incomplete: Couldn't find scroll bar in scrapbook");
- end;
- else
- actionPassed:= RIncomplete("Incomplete: Unknown type for finding - add type {requested} to scrapbook routine.");
- end;
- else
- actionIllegal := true;
- end;
- else if action[1] = "verify"
- begin
- if typeOf(action[2]) = 'string'
- begin
- requested := action[2];
-
- checkList:= assoc( requested, scrapTypes);
- if checkList
- begin
- if typeof(bitDepth) <> 'integer'
- bitDepth := VUAid("GetDepth");
- expected := whichCheckSum(checkList, bitDepth);
- actual := VUAid("CompareWindowRect", scrapTypeRect);
- if actual = expected
- RStatus("Verified that entry was of type {requested}", 4);
- else
- actionPassed:= RError("Failed: Entry was not of type {requested} - actual: {actual} expected: {expected}");
- end;
- else
- RIncomplete("Incomplete: Unknown type for verification - add type {requested} to scrapbook routine.");
- end;
- else
- actionIllegal := true;
- end;
- else
- actionIllegal:= true;
- end;
- else if typeof(action) = 'string'
- actionIllegal := not select_menuItem(action);
- else
- actionIllegal := true;
-
- if actionIllegal
- RIncomplete("Incomplete: ScrapBook handler recieved unknown action: {action}");
- end;
- return actionPassed or (not actionIllegal);
- end; # scrapbook()
-
-
- #########################################################################
- # task readScrollingList(itemInfoList, listParameterBlock)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Reads the order of items in a scrolling list using VUAid
- # to determine item types - ideal for things like the Chooser
- # Parameters: itemInfoList: {noItemInfo, item1Info, ... , itemNInfo }
- # itemNinfo: { itemName, selectedChecksumList, deselectedChecksumList,
- # userItem1 (optional), ... , userItemN (optional) }
- # Note: noItemInfo should always appear fist in the list,
- # and contains information about empty list spaces.
- # listParameterBlock :
- # {
- # {itemsAcross, itemsDown}, # Items visible in list
- # wholeListRect, # Rect {left, top, right, bottom} of whole list
- # firstItemRect, # Rect of first item in list
- # {horizontalOffset, verticalOffset},
- # # Horizontal, vertical item offset, or
- # # what to add to firstItemRect to get
- # # secondItemRect, thirdItemRect, etc.
- # scrollDownMaxRect # Rect of the lower portion of scrollbar
- # # in max downward position - what works best is
- # # just the scrollthumb
- # scrollDownMaxChecksums # Checksum list for scroll down max
- # scrollDownMaxDisabled # Checksum list for scroll bar disabled
- # scrollUpArrowLoc, # Location of Scroll Up arrow {h,v}
- # scrollDownArrowLoc, # Location of Scroll Down arrow
- # itemNameType # Name of list items type
- # };
- # Returns: list of found items, in format of itemInfoList.
- # Examples: println readScrollingList(gChooserIconsInfo, gChooserParameterBlock);
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 5/21/92 Jon Marsh Created
- #########################################################################
- task readScrollingList(itemInfoList, listParameterBlock)
- begin
- itemCounts := listParameterBlock[1];
- listRect := listParameterBlock[2];
- item1Rect := listParameterBlock[3];
- itemOffset := listParameterBlock[4];
- maxScrollRect := listParameterBlock[5];
- maxScrollChecksums := listParameterBlock[6];
- scrollDisabledChecksums := listParameterBlock[7];
- scrollUpArrowLoc := listParameterBlock[8];
- scrollDownArrowLoc := listParameterBlock[9];
- itemTypeName := listParameterBlock[10];
-
- itemList:= {};
- bitDepth := VUAid("GetDepth");
- grays := VUAid("GetGray");
- noErr:= true;
- currentlySelected:= 0;
- currentItem:= 0;
- scrollDown:= true;
-
- rStatus("Reading scrolling list of {itemTypeName}s", 4);
- move_mouse({ scrollUpArrowLoc, 'down', 'wait3', 'up' });
-
- while scrollDown #per scroll position
- begin
- for i:= 1 to itemCounts[2] #vertical per view area
- begin
- for j:= 1 to itemCounts[1] #horizontal per view area
- begin
- currentItem:= currentItem + 1;
- #get checksum for area where we expect an item
- itemRect := { item1Rect[1] + (j-1)*itemOffset[1],
- item1Rect[2] + (i-1)*itemOffset[2],
- item1Rect[3] + (j-1)*itemOffset[1],
- item1Rect[4] + (i-1)*itemOffset[2] };
- check := VUAid("CompareWindow32Rect", itemRect);
- rStatus("Looking for {itemTypeName} in position {currentItem} - ckSum: {check}", 4);
-
- found:= false;
- k:= 1; #k loops through known item types
- while (not found) and (k <= card itemInfoList)
- begin
- #check the checksums for selected items
- if check = whichCheckSum(itemInfoList[k][2], bitDepth, grays)
- begin
- found:= true; #add the found item to our list of current item
- thisItem:= itemInfoList[k][1]; #remember the name for logging
- if thisItem <> "none"
- itemList:= itemList + {itemInfoList[k]};
- end;
- #check the checksums for de-selected items
- else if check = whichCheckSum(itemInfoList[k][3], bitDepth, grays)
- begin
- found := true; #add the found item to our list of current items
- thisItem := itemInfoList[k][1]; #remember the name for logging
- if thisItem <> "none"
- itemList := itemList + {itemInfoList[k]};
- if currentlySelected = 0 #Remember which item is selected
- currentlySelected := card itemList;
- else
- rError("Failed: Multiple {itemTypeName}s selected: {itemTypeName}s {currentlySelected} and {currentItem}");
- end;
-
- k:= k+1;
- end;
- if found
- rStatus("Found item {thisItem}", 4);
- else
- rError("Failed: Unknown checksum ∂'{check}∂' for {itemTypeName} in position {currentItem}");
- end;
- end;
- #See if we've already scrolled down all the way, or if
- # the scroll bar is disabled.
- check := VUAid("CompareWindow32Rect", maxScrollRect);
- scrollDown := (check <> whichCheckSum(maxScrollChecksums, bitDepth, grays)) and
- (check <> whichCheckSum(scrollDisabledCheckSums, bitDepth, grays));
-
- # If the list didn't change visually after
- # scrolling, we probably have an unknown
- # checkSum for the scroll bar.
- if scrollDown
- begin
- check:= VUAid("CompareWindow32Rect", listRect);
- move_mouse({ scrollDownArrowLoc, 'click' });
- if VUAid("CompareWindowRect", listRect) = check
- scrollDown:= rIncomplete("Attempt to scroll {itemTypeName} list failed - Scroll bar checksum: {check}");
- end;
- end;
- if currentlySelected < 1
- rError("Warning: No recognized {itemTypeName} is currently selected.");
- if card itemList < 1
- rError("Failed: No {itemTypeName}s found");
-
- if rXStatus(4)
- println "List of found {itemTypeName}s: ", itemList;
- return itemList;
- end;
-
- #########################################################################
- # task offset_list( a, b, v_level )
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Adds the elements of two lists so one list results.
- # Use it to easily add offsets to rectangles and points.
- # Parameters: a,b: Lists of integers; each can have 2 or 4 elements.
- # If they are not the same length the smaller is
- # appended to itself
- # v_level: verbosity level for log output
- # Returns: list with 2 or 4 items, each one equals a[n] + b[n]
- # Assumptions:
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 01/19/93 SBR Created
- # 09/18/94 SBR Added trace hiding.
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # Added this header
- #########################################################################
- task offset_list( a := {}, b := {}, v_level := 5 )
- begin
- saveTrace := trace(false);
-
- if card a < card b
- a := a + a;
- else if card a > card b
- b := b + b;
- if card a = 2
- begin
- if v_level > 7
- println "offset_List: a: ",a," b: ",b, " total: ",{ a[1]+b[1], a[2]+b[2] };
- returnValue := { a[1]+b[1], a[2]+b[2] };
- trace(saveTrace);
- return returnValue;
- end;
- else if card a = 4
- begin
- returnValue := { a[1]+b[1], a[2]+b[2], a[3]+b[3], a[4]+b[4] };
- trace(saveTrace);
- return returnValue;
- end;
- else
- RIncomplete("offset_list: lengths of a and b must be 2 or 4",1);
-
- end;
-
-
-
- #########################################################################
- # task CenterOfWindowClick()
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Clicks in the center of the top window.
- # Parameters:
- # Returns:
- # Assumptions:
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # Added this header
- #########################################################################
- task CenterOfWindowClick()
- begin
- try
- match [window o:1 r:?WindRect];
- catch theError
- ExceptionDispatcher(theError,,{"match in CenterOfWindowClick 1", {[window o:1], true}});
-
- XCoord := (WindRect[3] - WindRect[1])/2;
- YCoord := (WindRect[4] - WindRect[2])/2;
- move_mouse({{XCoord,YCoord}, 'click'});
- # println ' "move_mouse", { ', {XCoord,YCoord}, ', "click"},';
-
- try
- match [window o:1 r:?NewRect]; #In case an about dialog needs multiple clicks to make it go away
- catch theError
- ExceptionDispatcher(theError,,{"match in CenterOfWindowClick 2", {[window o:1], true}});
-
- if NewRect = WindRect
- CenterOfWindowClick();
- end;
-
-
- #########################################################################
- # task hexStr_to_dec(hexValue)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Converts a hex string between '0000'-'7fff' to an
- # integer between 0-32767.
- # Parameters:
- # Returns:
- # Assumptions:
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 09/27/96 BRL Added this header
- #########################################################################
- task hexStr_to_dec(hexValue := '0000')
- begin
- hexits := {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
- decValue := 0;
- hexPlaces := {4096,256,16,1};
- for i := card hexValue to 1 step -1
- begin
- temp := (hexPlaces[i] * (ismember(hexValue[i], hexits) - 1));
- decValue := decValue + temp;
- end;
- return decValue;
- end;
-
-
- #########################################################################
- # task dec_to_hexStr(decValue)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Converts an integer between 0-32767 to a hex string
- # between '0000'-'7fff'.
- # Parameters:
- # Returns:
- # Assumptions:
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # Added this header
- #########################################################################
- # task dec_to_hexStr(decValue := 0)
- # begin
- # hexits := '0123456789ABCDEF';
- # hexPlaces := {4096,256,16,1};
- # hexValue := '';
- # for i := 1 to card hexPlaces begin
- # temp := decValue / hexPlaces[i];
- # hexValue := hexValue + hexits[temp + 1];
- # decValue := decValue - temp * hexPlaces[i];
- # end;
- # return hexValue;
- # end;
-
-
-
-
- #########################################################################
- # task dec_to_hexStr(decValue)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Converts a long integer to a hex string between
- # '0'-'FFFFFFFF' without the '0x'.
- # Parameters:
- # Returns:
- # Assumptions:
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # Added this header
- #########################################################################
- task dec_to_hexStr(decValue := 0)
- begin
- hexValue := numToStr(decValue);
-
- hexString := '';
- for i := 3 to card hexValue
- begin
- hexString := hexString + hexValue[i];
- end;
- return hexString;
- end;
-
-
-
- #########################################################################
- # task unexpected_dialog(expectedItem, expectedDesc, v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Tries to dismiss unexpected dialogs in standard ways.
- # Parameters:
- # Returns:
- # Assumptions:
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 09/27/96 BRL/MSO Added SPEC exception handling
- # Added this header
- #########################################################################
- task unexpected_dialog(expectedItem := "", expectedDesc := {[]}, v_level := 4)
- begin
- try
- match [target t:?tName];
- catch theError
- ExceptionDispatcher(theError,,{"match 1 in unexpected_dialog", {expectedItem, expectedDesc, v_level}});
-
- if expectedItem = "desc" #a dialog box may be the expected!
- if _MatchBoolean(expectedDesc[1])
- return false;
-
- try
- match [window s:?windStyle o:1 k:?kList r:?windRect]!;
- catch theError
- ExceptionDispatcher(theError,,{"match 2 in unexpected_dialog", {expectedItem, expectedDesc, v_level}});
-
- if not isMember(windStyle, {dialog, moveablemodal}) #no dialog
- return false;
-
- topWind := [window s:windStyle k:kList r:windRect];
-
- (*Collect the staticText items*)
- staticList := kList;
-
- for i := card staticList to 1 step -1
- begin
- if (descType(staticList[i]) <> 'staticText')
- staticList := remove(i, staticList);
- end;
-
- if card staticList = 1
- temp := staticList[1].t;
- else if card staticList = 0
- temp := "no staticText strings present";
- else
- temp := "multiple staticText strings, one is: " + staticList[1].t;
- RStatus("unexpected_dialog: {temp}", v_level);
-
- (*Try the escape key*)
- type_keys({escapeKey});
- RStatus("unexpected_dialog: pressed the escape key", v_level);
- if await_absence(topWind,2,,,6)
- return true;
-
- (*Put button titles into a list*)
- buttonList := {};
- for i := 1 to card kList
- begin
- thisContentItem := kList[i];
- if thisContentItem.e and (descType(thisContentItem) = 'button')
- buttonList := buttonList + {thisContentItem.t};
- end;
-
- (*If there is just one enabled button, select it*)
- if (card buttonList = 1)
- begin
- temp := buttonList[1];
- if not (temp ~= /≈launch≈/)
- begin
- _Select([button t:temp w:1], true);
- RStatus("unexpected_dialog: selected only enabled button {temp}", v_level);
- end;
- end;
- if await_absence(topWind,2,,,6)
- return true;
-
- (*If there are no enabled buttons, signal a warning*)
- else if (card buttonList < 1)
- begin
- CenterOfWindowClick();
- RStatus("unexpected_dialog: clicked in the center of the window", v_level);
- if await_absence(topWind,2,,,6)
- return true;
- else
- begin
- RStatus("unexpected_dialog: no way out -- need human intervention", v_level);
- RStatus("{tName} IS STUCK IN A DIALOG! PLEASE DISMISS IT TO CONTINUE THE SCRIPT…",1);
- while not await_absence(topWind,60,,,6)
- SysBeep();
- return true;
- end;
- end;
- else for each goodTry in {'Cancel','Done','OK','No','Yes'}
- begin
- if isMember(goodTry, buttonList)
- begin
- _Select([button t:goodTry w:1], true);
- RStatus("unexpected_dialog: selected button named {goodTry}", v_level);
- if await_absence(topWind,2,,,6)
- return true;
- end;
- end;
- RStatus("unexpected_dialog: {buttonList}", v_level);
- for i := 1 to card buttonList
- begin
- if buttonList[i].t <> ''
- begin
- if _MatchBoolean(buttonList[i])
- begin
- temp := buttonList[i].t;
- _Select([button t:temp]);
- if _MatchBoolean([window s:dialog o:1]) or _MatchBoolean([window s:movablemodal o:1])
- unexpected_dialog(,,v_level);
- end;
- if not (_MatchBoolean([window s:dialog o:1]) or _MatchBoolean([window s:movablemodal o:1]))
- i := card buttonList;
- end;
- end;
- end;
-
- #########################################################################
- # task abort_app(v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Guarantees when done that the app is not active or in the process menu.
- # Parameters: v_level: verbosity level for log output
- # Returns: nothing (will not return until successful)
- # Assumptions: VU 2.0.1
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 07/25/90 Alan Liu Creation as part of ApplicationLib.vu for 007
- # 03/04/92 Jason Marsh Incorporation into Clouseau.Lib.
- # 03/20/93 SBR Redesigned for use with Launchquits.lib
- # 08/06/93 SBR Changed to match[target] which forces target access
- # 02/19/94 SBR Moved to Clouseau.lib from Launchquits.lib
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task abort_app(v_level := 4)
- begin
- AddExceptionHandler(-1105, { task EH_CrashRecover, {'',2,15}});
- theTarget := _Match([target]);
- RemoveExceptionHandler(-1105);
-
- if not theTarget
- RError("abort_app: Target crashed.", v_level);
- else
- begin
- currentApp := (_Match([target]).a)[1].t;
- if currentApp = 'Finder'
- return RStatus("abort_app: Can not abort the Finder.",v_level);
- appToAbort := currentApp;
- quitMethod := 1;
- RStatus("abort_app: Attempting to quit '{currentApp}' by any possible method.", v_level);
-
- while appToAbort = currentApp
- begin
- if quitMethod = 1
- begin
- key_eq('q');
- quitMethod := 2;
- RStatus("abort_app: tried command-Q.", v_level);
- end;
-
- else if quitMethod = 2
- begin
- select_menuItem('Quit');
- quitMethod := 3;
- RStatus("abort_app: tried selecting Quit from the File menu.", v_level);
- end;
-
- else if quitMethod = 3
- begin
- if not unexpected_dialog(,,v_level)
- if not close_window()
- select_descriptor([button t:"Cancel" e:true]);
- quitMethod := 1;
- RStatus("abort_app: Tried dismissing the front window/dialog.", v_level);
- end;
-
- await_absence([application t:currentApp],5,,,6);
-
- currentApp := (_Match([target]).a)[1].t;
- RStatus("abort_app: Current app is '{currentApp}'.", v_level);
- end;
- end;
- end;
-
-
- #########################################################################
- # task quit_all(v_level)
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # Description: Quit all applications, leaving us in the Finder. First
- # check if we are in MultiFinder. Next, if we are not in
- # MultiFinder, check if we are in the Finder already --
- # if not, then quit the current application. If we are in
- # MultiFinder, then check if we are in the Finder. Click
- # on the twitch icon. If we aren't in the Finder, then quit
- # this app and try again, until we are in the Finder twice
- # (before and after clicking on the twitch icon).
- # Parameters: v_level: verbosity level for log output
- # Returns: true
- # Examples: quit_all();
- # Assumptions: None
- #∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞∞
- # History:
- # 7/25/90 Alan Liu Creation as part of FinderLib.vu for 007
- # 3/4/92 Jason Marsh Incorporated into Clouseau.Lib
- # 09/27/96 BRL/MSO Added SPEC exception handling
- #########################################################################
- task quit_all(v_level:=5)
- begin
- try
- match[application t:?oldApp]!;
- catch theError
- ExceptionDispatcher(theError,,{"match in quit_all 1", {[application], true}});
-
- done := false;
- while (not done)
- begin
- while (oldApp <> "Finder")
- begin
- if not(abort_app(v_level))
- return false;
-
- try
- match[application t:?oldApp]!;
- catch theError
- ExceptionDispatcher(theError,,{"match in quit_all 2", {[application], true}});
- end;
- twitch();
-
- try
- match [application t:?newApp]!;
- catch theError
- ExceptionDispatcher(theError,,{"match in quit_all 3", {[application], true}});
-
- if (newApp = "Finder")
- done := true;
- else
- oldApp := newApp;
- end;
- return true;
- end;
-
-
- (*____________________________________________________________________________*)
- # task hexDecTest(val := 0) begin
- # if typeOf(val) = 'string' begin
- # i := hexStr_to_dec(val);
- # j := dec_to_hexStr(i);
- # println "hex value: '{val}'; dec value: {i}; hex value '{j}'";
- # end;
- #
- # else if typeOf(val) = 'integer' begin
- # i := dec_to_hexStr(val);
- # j := hexStr_to_dec(i);
- # println "dec value: {val}; hex value: '{i}'; dec value {j}";
- # end;
- # end;
-